﻿@using Microsoft.AspNetCore.Http.Extensions
@using NewLife.Common;
@{
    var retUrl = Context.Request.GetEncodedPathAndQuery();

    var user = ViewBag.User as IUser ?? User.Identity as IUser;
    var uid = 0;
    var roleNames = "";
    if (user != null)
    {
        uid = user.ID;
        roleNames = user.Roles == null ? "" : user.Roles.Join();
    }
    var cfg = ViewBag.Config as SysConfig;
    if (cfg == null) cfg = SysConfig.Current;
    var name = cfg == null ? "" : cfg.DisplayName;
}
<header class="navbar navbar-expand-md navbar-light d-print-none">
    <div class="container-xl">
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar-menu">
            <span class="navbar-toggler-icon"></span>
        </button>
        <h1 class="navbar-brand navbar-brand-autodark d-none-navbar-horizontal pe-0 pe-md-3">
            <a href=".">
                <img src="/Content/images/logo/NewLife.png" width="110" height="32" alt="Tabler" class="navbar-brand-image">
            </a>
        </h1>
        <h1>
            @name
        </h1>
        <div class="navbar-nav flex-row order-md-last">
            @*<div class="nav-item d-none d-md-flex me-3">
                <div class="btn-list">
                <a href="https://github.com/tabler/tabler" class="btn btn-outline-white" target="_blank" rel="noreferrer">
                <svg xmlns="http://www.w3.org/2000/svg" class="icon text-github" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M9 19c-4.3 1.4 -4.3 -2.5 -6 -3m12 5v-3.5c0 -1 .1 -1.4 -.5 -2c2.8 -.3 5.5 -1.4 5.5 -6a4.6 4.6 0 0 0 -1.3 -3.2a4.2 4.2 0 0 0 -.1 -3.2s-1.1 -.3 -3.5 1.3a12.3 12.3 0 0 0 -6.2 0c-2.4 -1.6 -3.5 -1.3 -3.5 -1.3a4.2 4.2 0 0 0 -.1 3.2a4.6 4.6 0 0 0 -1.3 3.2c0 4.6 2.7 5.7 5.5 6c-.6 .6 -.6 1.2 -.5 2v3.5" /></svg>
                Source code
                </a>
                <a href="https://github.com/sponsors/codecalm" class="btn btn-outline-white" target="_blank" rel="noreferrer">
                <svg xmlns="http://www.w3.org/2000/svg" class="icon text-pink" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M19.5 13.572l-7.5 7.428l-7.5 -7.428m0 0a5 5 0 1 1 7.5 -6.566a5 5 0 1 1 7.5 6.572" /></svg>
                Sponsor
                </a>
                </div>
                </div>*@
            <div class="nav-item dropdown">
                <a href="#" class="nav-link d-flex lh-1 text-reset p-0" data-bs-toggle="dropdown" aria-label="Open user menu">
                    <span class="avatar avatar-sm" style="background-image: url(@user.GetAvatarUrl())"></span>
                    <div class="d-none d-xl-block ps-2">
                        <div>@user</div>
                        <div class="mt-1 small text-muted">@roleNames</div>
                    </div>
                </a>
                <div class="dropdown-menu dropdown-menu-end dropdown-menu-arrow">
                    <a href="/" class="dropdown-item" target="_blank">首页</a>
                    <a href="~/Admin/User/Info/@uid" class="dropdown-item">个人信息</a>
                    <div class="dropdown-divider"></div>
                    <a href="~/Admin/Cube" class="dropdown-item">系统设置</a>
                    <a href="~/Admin/User/Logout" class="dropdown-item">注销</a>
                </div>
            </div>
        </div>
    </div>
</header>
<div class="navbar-expand-md">
    <div class="collapse navbar-collapse" id="navbar-menu">
        <div class="navbar navbar-light">
            <div class="container-xl">
                @await Html.PartialAsync("_Layout_Menu")
            </div>
        </div>
    </div>
</div>
